home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / sbprolog / v3 / sim.lha / sim / sim.h < prev    next >
C/C++ Source or Header  |  1990-04-12  |  5KB  |  124 lines

  1. /************************************************************************
  2. *                                    *
  3. * The SB-Prolog System                            *
  4. * Copyright SUNY at Stony Brook, 1986; University of Arizona, 1987    *
  5. *                                    *
  6. ************************************************************************/
  7.  
  8. /*-----------------------------------------------------------------
  9. SB-Prolog is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY.  No author or distributor
  11. accepts responsibility to anyone for the consequences of using it
  12. or for whether it serves any particular purpose or works at all,
  13. unless he says so in writing.  Refer to the SB-Prolog General Public
  14. License for full details.
  15.  
  16. Everyone is granted permission to copy, modify and redistribute
  17. SB-Prolog, but only under the conditions described in the
  18. SB-Prolog General Public License.   A copy of this license is
  19. supposed to have been given to you along with SB-Prolog so you
  20. can know your rights and responsibilities.  It should be in a
  21. file named COPYING.  Among other things, the copyright notice
  22. and this notice must be preserved on all copies. 
  23. ------------------------------------------------------------------ */
  24. /* sim.h */
  25.  
  26. #include <stdio.h>
  27. #include <math.h>
  28.  
  29. #define  STR_LIM 256  /* limit on the length of the name of a constant */
  30. #define     SIMPATH_LEN 1024  /* limit on length of SIMPATH */
  31.  
  32. #define MAXREGS       257  /* registers 1-256 correspond to args 1-256 */
  33. #define MAXTRAPS      2
  34. #define WRITEFLAG     1
  35. #define READFLAG      0
  36. #define MAX_LEN       1280
  37. #define BUCKET_CHAIN  53
  38. #define null          0
  39. #define TRUE          1
  40. #define FALSE         0
  41. #define PERM          1
  42. #define TEMP          0
  43. #define CAR           1
  44. #define CDR           0
  45.  
  46. #define T_ORDI        0    /* constant-type: no ep definition */
  47. #define T_DYNA        1    /* constant-type: dynamic, code in buffer */
  48. #define T_PRED        2    /* constant-type: ep points to compiled code */
  49. #define T_BUFF        3    /* constant-type: no ep field at all */
  50. #define T_TEMP_PRED  15    /* psc entry for predicate containing offset
  51.                               entry point */
  52.  
  53. /* ---------- Type Specifiers ----------------------------------------------- */
  54.  
  55. typedef char                CHAR;     /*  8 bits */
  56. typedef unsigned char       BYTE;     /*  8 bits */
  57. typedef unsigned short int  WORD;     /* 16 bits */
  58. typedef long int            LONG;     /* 32 bits */
  59.  
  60. typedef CHAR  *CHAR_PTR;              /* pointers to memory types */
  61. typedef BYTE  *BYTE_PTR;
  62. typedef WORD  *WORD_PTR;
  63. typedef LONG  *LONG_PTR;
  64.  
  65. typedef struct psc_rec {
  66.    BYTE      entry_type;
  67.    BYTE      arity;
  68.    WORD      length;
  69.    CHAR_PTR  nameptr;
  70.    LONG_PTR  ep;         /* entry point, various meanings */
  71.    } *PSC_REC_PTR;
  72.  
  73. /* ---------- External variable declarations -------------------------------- */
  74.  
  75. extern LONG      maxmem, maxpspace, maxtrail;  /* declared in init.c */
  76.  
  77. extern LONG_PTR  memory;          /* heap, local stack   */
  78. extern LONG_PTR  pspace;          /* psc records, instructions, p-names */
  79. extern LONG_PTR  tstack;          /* trail stack */
  80. extern LONG      reg[MAXREGS];    /* general purpose registers */
  81.  
  82. extern LONG_PTR  local_bottom;
  83. extern LONG_PTR  heap_bottom;
  84. extern LONG_PTR  trail_bottom;
  85.  
  86. extern CHAR_PTR  curr_fence;      /* ptr to next free byte in perm space */
  87. extern CHAR_PTR  max_fence;       /* ptr to last+1 free byte in perm space */
  88. extern WORD_PTR  inst_begin;      /* ptr to the beginning of inst. array */
  89.  
  90. extern LONG_PTR  ereg;            /* last activation record       */
  91. extern LONG_PTR  breg;            /* last choice point            */
  92. extern LONG_PTR  hreg;            /* top of heap                  */
  93. extern LONG_PTR  trreg;           /* top of trail stack           */
  94. extern LONG_PTR  hbreg;           /* heap backtrack point         */
  95. extern LONG_PTR  sreg;            /* current build or unify field */
  96. extern LONG_PTR  cpreg;           /* return point register        */
  97. extern WORD_PTR  pcreg;           /* program counter              */
  98.  
  99. extern LONG_PTR  mheaptop, mlocaltop, mtrailtop;
  100. extern int       pspace_used;     /* heap_used, stack_used, trail_used */
  101.  
  102. extern LONG_PTR  trap_vector[MAXTRAPS];
  103. extern LONG_PTR  hash_table[BUCKET_CHAIN][2];
  104.  
  105. extern LONG      oprnd1, oprnd2, oprnd3;
  106.  
  107. extern WORD      flags[10];       /* user flags from command line: -u[0-9] */
  108. extern BYTE      trace;           /* (0) 1 = trace on, 0 = trace off     */
  109. extern BYTE      hitrace;         /* (1) 1 = hitrace on, 0 = hitrace off */
  110. extern BYTE      overflow_f;      /* (2) 1 = ignore stack overflow       */
  111. extern BYTE      disassem;
  112. extern BYTE      trace_sta;       /* 1 = keep max stack size stats */
  113. extern BYTE      call_intercept;  /* hitrace or trace_sta for efficiency */
  114. extern int       num_line;        /* print instruction addresses on trace
  115.                      and disassem */
  116.  
  117. extern LONG      nil_sym, list_str;
  118.  
  119. extern int       interrupt_code;
  120.  
  121. extern PSC_REC_PTR  list_psc;
  122. extern PSC_REC_PTR  interrupt_psc;
  123. extern PSC_REC_PTR  comma_psc;
  124.